import 'package:flutter/material.dart';
import 'package:flutterdemo/smartform/container/StackPage.dart';
import 'package:flutterdemo/smartform/homepage.dart';
import 'package:flutterdemo/smartform/page/NestedScrollPage2.dart';

/// 参考：
/// https://book.flutterchina.club/

/// 路由名常量
class KeyConstant{
  static const String PAGE_STACK = "StackPage";
  static const String PAGE_LIFECYCLE = "liftcycle";
  static const String PAGE_CEILING_LIST = "ceilingList";
}

/// 路由名中英映射
Map<String, String> routesNameMap = {
  KeyConstant.PAGE_STACK : "Stack容器",
  KeyConstant.PAGE_LIFECYCLE : "生命周期",
  KeyConstant.PAGE_CEILING_LIST: "吸顶list"
};

/// 路由表
Map<String, WidgetBuilder> genarateRoutes(BuildContext context){
  return {
    KeyConstant.PAGE_STACK : (context) => StackPage(),
    KeyConstant.PAGE_LIFECYCLE : (context) => StackPage(),
    KeyConstant.PAGE_CEILING_LIST: (context) => NestedScrollPage(),
  };
}

RouteObserver routeObserver = RouteObserver();

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    print("object");

    var routes = genarateRoutes(context);
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
        backgroundColor: Colors.white
      ),
      navigatorObservers: [routeObserver],
      routes: routes,
      onGenerateRoute: (RouteSettings settings){

      },
      home: HomePage(),
    );
  }
}

